<?php
namespace App\Common\Lib\Err\Exception;

use App\Common as com;
use App\Common\Lib\Err\Exception\ExtExternal as nameExtExternal;
use App\Common\Lib\Err as nameErr;

class ExtExternal extends nameErr\BaseException\Throw_ {

	public static int $varExternalType_Ys7 = 1;

	private array $externalErrorInfo = [
		'type' => 0,
		'status' => 0,
		'statusStr' => '',
	];

	public function setExternalInfo( int $type, int $code, string $msg, array $otherData = [] ):self {
		$this->externalErrorInfo = [
			'type' => $type,
			'status' => $code,
			'statusStr' => com\Cla\Port\Ys7\App\Api\ErrorCode::$codeMap[ $code ] ?? '',
			'originalData' => [
				'code' => $code,
				'msg' => $msg,
			]
		];
		//
		com\Lib\Fun\Array_::arrayMerges( $this->externalErrorInfo, $otherData );
		//
		return $this;
	}

	public function getExternalInfo(  ):array {
		return $this->externalErrorInfo;
	}

	public function getExternalType(  ):int {
		return $this->getExternalInfo()['type'];
	}

	public function getExternalStatus(  ):int {
		return $this->getExternalInfo()['status'];
	}

}
